<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">

    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import accountStatement from '@/api/finance/accountStatement'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()

const options = reactive({
  id: 'account_statement',
  pageLayout: 'fixed',
  rowSelection: {
    showCheckedAll: true
  },
  requestParams: {
    orderBy : 'id',
    orderType : 'desc'
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: 600
  },
  api: accountStatement.getList,
  tabs:{
    dataIndex: "account_type"
  },
  add: {
    // show: true,
    api: accountStatement.save,
    auth: ['finance:accountStatement:save']
  },
  edit: {
    // show: true,
    api: accountStatement.update,
    auth: ['finance:accountStatement:update']
  },
  export: {
    show: true,
    url: 'finance/accountStatement/export',
    auth: ['finance:accountStatement:export']
  }
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "流水号",
    dataIndex: "as_number",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入流水号"
    }
  },
  {
    title: "账户",
    dataIndex: "account_id",
    dict: {
        url: 'finance/financialAccount/list',
        props: {label: 'name', value: 'id'} ,
        // params: {select: 'id,name'},
        translation: true,
      }, 
    formType: "select",
    search: true,
  },
  {
    title: "账户所属",
    dataIndex: "user",
    formType: "select",
  },
  {
    title: "账户类型",
    dataIndex: "account_type",
    formType: "select",
    search: true,
    commonRules: {
      required: true,
      message: "请输入账户类型"
    },
    dict: {
      name: 'FinancialAccountType',
      props: {
        label: "title",
        value: "key"
      },
      translation: true,
    },
  },
  {
    title: "币种",
    dataIndex: "currency_type",
    formType: "select",
    dict: {
      name: "currencyType",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
      }
  },
  {
    title: "流水id",
    dataIndex: "statement_id",
    formType: "input",
    // search: true,
    hide:true,
    commonRules: {
      required: true,
      message: "请输入流水id"
    }
  },
  {
    title: "账单类型",
    dataIndex: "bill_type",
    formType: "select",
    dict: {
      name: "FinancialStatementType",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
      },
    hide: true
  },
  {
    title: "账单id",
    dataIndex: "bill_id",
    formType: "input",
    hide: true
  },
  {
    title: "金额",
    dataIndex: "amount",
    formType: "input",
  },
  {
    title: "手续费",
    dataIndex: "service_charge",
    formType: "input",
  },
  {
    title: "入账金额",
    dataIndex: "real_add",
    formType: "input",
  },
  {
    title: "交易类型",
    dataIndex: "trade_type",
    dict: {
      name: "AmountType",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
      },
    formType: "select",
    // hide: true
  },
  {
    title: "交易下的费用类型",
    dataIndex: "amount_type",
    formType: "input",
    hide: true
  },
  {
    title: "是否还能撤销",
    dataIndex: "is_check",
    formType: "input",
    hide: true
  },
  {
    title: "是否支付默认支付",
    dataIndex: "is_pay",
    formType: "input",
    hide: true
  },
  {
    title: "撤销的核销记录 id",
    dataIndex: "pid",
    formType: "input",
    hide: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "range",
    addDisplay: false,
    editDisplay: false,
    search:true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
  }
])
</script>
<script> export default { name: 'finance:accountStatement' } </script>